package com.xiaoKe.zhonghzu.global.base;

import android.content.Context;
import android.util.AttributeSet;

import androidx.recyclerview.widget.RecyclerView;

import com.scwang.smart.refresh.layout.SmartRefreshLayout;
import com.scwang.smart.refresh.layout.api.RefreshLayout;
import com.scwang.smart.refresh.layout.listener.OnLoadMoreListener;
import com.scwang.smart.refresh.layout.listener.OnRefreshListener;
import com.xiaoKe.zhonghzu.R;

/**
 * @ProjectName : xiaoke-pad-zhongzhu
 * @Author : Shijingna
 * @Time : 2024/7/30 17:27
 * @Description : 文件描述
 */
public class BaseRefreshLayout  extends com.scwang.smart.refresh.layout.SmartRefreshLayout{

    //         // TODO 完成加载更多，参数2：是否刷新成功；参数2：是否还有更多数据
    //                binding.smartRefreshLayout.finishLoadMore(500, true, true);

    public BaseRefreshLayout(Context context) {
        super(context);
    }

    public BaseRefreshLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
    }
    SmartRefreshLayout smartRefreshLayout;
    RecyclerView recyclerView;
    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
        smartRefreshLayout = findViewById(R.id.smartRefreshLayout);
        recyclerView = findViewById(R.id.recyclerView);
    }
    public SmartRefreshLayout getSmartRefreshLayout() {
        return smartRefreshLayout;
    }

    public RecyclerView getRecyclerView() {
        return recyclerView;
    }

    public RefreshLayout setOnRefreshListener(OnRefreshListener listener) {
        smartRefreshLayout.setOnRefreshListener(listener);
        return null;
    }

    public RefreshLayout setOnLoadMoreListener(OnLoadMoreListener listener) {
        smartRefreshLayout.setOnLoadMoreListener(listener);
        return  this;
    }

    public RefreshLayout finishRefresh(boolean success) {
        smartRefreshLayout.finishRefresh(success);
        return  this;
    }

    public RefreshLayout finishLoadMore(boolean success) {
        smartRefreshLayout.finishLoadMore(success);
        return  this;
    }
}
